package com.qf.springbootshiro.user.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.springbootshiro.user.entity.Pers;
import com.qf.springbootshiro.user.entity.Role;
import com.qf.springbootshiro.user.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author XvYingHai
 * @since 2022-10-25
 */
@Mapper
public interface UserDao extends BaseMapper<User> {
    @Select("select * from t_role where id in(select roleid from t_user_role where userid=#{user.id})")
    List<Role> getRoleByUser(@Param("user") User user);

    @Select("select * from t_pers where id in(select permsid from t_role_perms where roleid in(select roleid from t_user_role where userid=#{user.id}))")
    List<Pers> getPermissionsByUser(@Param("user") User user);

}
